package com.hotel.common;

public class AjaxResult {

    // 请求成功
    public final static String SUCCESS = "OK";
    // 请求失败
    public final static String ERROR = "ERROR";

    // 请求成功与否
    private String code;
    // 返回消息
    private String msg;
    // 返回的json数据
    private Object data;

    public AjaxResult() {
    }
    public AjaxResult(String code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static AjaxResult queryAjax(Object data){
        return new AjaxResult(AjaxResult.SUCCESS, "操作成功", data);
    }

    public static AjaxResult updateAjax(int data){
        AjaxResult ajaxResult = new AjaxResult();
        if(data > 0){
            ajaxResult.setCode(AjaxResult.SUCCESS);
            ajaxResult.setMsg("操作成功");
        }else {
            ajaxResult.setCode(AjaxResult.ERROR);
            ajaxResult.setMsg("操作失败");
        }
        ajaxResult.setData(data);
        return ajaxResult;
    }



}
